#!/bin/sh

# Replace _VER_ with an actual version number for all text files in a directory

if [ $# != 2 ]; then
  echo "setver: Usage: setver version directory" >&2
  exit 1
fi

# set -x
tmp=/tmp/setver.$$

find "$2" -type f |
while read f; do
  file "$f" | grep -q text && 
  (sed "s/_VER_/$1/g" "$f" > $tmp && (cp -f $tmp "$f"; rm $tmp))
done

exit 0
